<?php
require_once "functions.php";
require_once "SelectField.php";

//$allFriends = getAllFriends();

echo "<form name=\"sendForm\" method='POST'>\n";
 
if($_POST["toorder"])
  {
  $orderA = explode("_",$_POST["toorder"]);
  $orderby = $orderA[0];
  $orderit = $orderA[1];
   }

if($orderby==""){$orderby="AddDate";}
if($orderit==""){$orderit="DESC";}

$allFriends=getAllFriends($orderby,$orderit, $_POST["serchefor"]);

echo '<input type="text" name="serchefor" value="'.$_POST["serchefor"].'"> ';
$OrderSelect=new SelectField("sercheby");
$OrderSelect->append_option("Alle","",($_POST["sercheby"]==""));
$OrderSelect->append_option("Name","name",($_POST["sercheby"]=="name"));
echo $OrderSelect->print_html();
echo '<input class="submit_button" type="submit" name="submitit"  value="Suche">';
echo '<input type="hidden" name="toorder" value="">';

	$headline="<h3>Friends</h3>";
	$count = numRows($allFriends);
	$type_of_list="Friends";
	$width="75%";
	@require('browser.php');
		
	echo "
	<table class=\"dbList\" width='$width'>
	\n";

	$index=1;
	$row=1;
	while ($data = mysql_fetch_array($allFriends)) 
	{

		if ($index>=$displayFrom && $index<=$displayTo)
		{
			if($row==1){
				echo "<tr>";
			}elseif (($row==6)||($row==11)||($row==16)||($row==21)||($row==26)||($row==31)||($row==36)
				||($row==41)||($row==46)||($row==51)||($row==56)){
				echo "</tr><tr>";
			}
			
			$view_link	= "<a href='http://friends.myspace.com/index.cfm?fuseaction=user.viewprofile&friendID=".$data["id"]."'>".$data["name"];
			$picture = str_replace("s_", "m_",$data["pic"]);
			echo "
			<td align=\"center\">".$view_link."<br>
			<img src=\"".$picture."\"></a></td>
			\n";
			if (($row==60)){
				echo "</tr>";
			}
			$row++;
		}
		$index++;
	}

	echo "
	</table>
	</form>\n";



?>